<?php 
class siteOptions extends record
{
	
	function __construct()
	{
		parent::__construct();
	}
	function getCaraPesan(){
		$this->namaTabel='atribut';
		$this->get('*',array(),null,null,null,null,'(nama IN("cara_pesan"))');
		$wW = $this->execute();		
		$dtW = (isset($wW['result']) && $wW['total']==1)?$wW['result']:array(0=>array('nama'=>'cara_pesan','nilai'=>''));
		$re['nama']=$dtW[0]['nama'];
		$re['nilai']=$dtW[0]['nilai'];
		return $re;
		
	}
	function get_bykey($key){
$this->namaTabel='atribut';
		$this->get('nilai',array('nama'=>$key),1);
		
		$ex=$this->execute();
		return $ex['total']>0?$ex['result'][0]['nilai']:'';
	}
	function getWhoWe(){
		$this->namaTabel='atribut';
		$this->get('*',array(),null,null,null,null,'(nama IN("benefit","who_we","about_us","cara_pesan"))');
		$wW = $this->execute();		
		$default=array(0=>array('nama'=>'who_we','nilai'=>''),1=>array('nama'=>'benefit','nilai'=>''));
		$dtW = isset($wW['result']) && $wW['total']>=3?$wW['result']:$default;
		$need=array('benefit','who_we','about_us','cara_pesan');
		foreach ($dtW as $key => $value) {
			if(in_array($value['nama'], $need)){
				$ben[$value['nama']]=$value['nilai'];
			};
		};
		return $ben;
	}
	
    function setSettings($nama,$nilai){
        $str = 'INSERT INTO atribut (nama, nilai)
        VALUES("'.$nama.'","'.$nilai.'") ON DUPLICATE KEY UPDATE nilai="'.$nilai.'"';
        $q = $this->query($str);
        return $this->execute();
    }
}
$objSiteOptions=new siteOptions();